<template>
  <div class="markdown-container" v-html="md.render(text)"></div>
</template>
<script setup lang="ts">
import MarkdownIt from 'markdown-it'
import iterator from 'markdown-it-for-inline'

defineProps<{
  text: string
}>()

const md = new MarkdownIt().use(iterator, 'rag_source', 'text', function (tokens, idx) {
  tokens[idx].content = tokens[idx].content.replace(/\[\^([^\]]+)\]/g, '<sup>$1</sup>')
})

md.renderer.rules.text = (tokens, idx, options, env, self) => {
  console.log(tokens[idx].content)
  return tokens[idx].content
}
</script>
